<?php 
	if (!$teste){
	include_once '../class/verifica_sessao.php';
	verifica_sessao();}
?>
<script language='Javascript' src='frame.js'></script>
<script language='Javascript' src='../class/calendar.js'></script>
<script language="javascript" src='../class/valida.js'></script>

<style>
    .dia {font-family: helvetica, arial; font-size: 8pt; color: #FFFFFF}
    .data {font-family: helvetica, arial; font-size: 8pt; text-decoration:none; color:#191970}
    .mes {font-family: helvetica, arial; font-size: 8pt}
    .Cabecalho_Calendario {font-family: helvetica, arial; font-size: 10pt; color: #000000; text-decoration:none; font-weight:bold}
</style>

<?php 
	$l1=''; #primeira leitura
	$l2='';#segunda leitura
	$s='';#salmo
	$e='';#evangelio
	$lv1='';#livro da primeira leitura
	$lv2="";#livro da segunda leitura
	$lv3="";#livro do salmo
	$lv4="";#livro do evangelio
	$p="";#palavra do padre
	$dat="data";
	
	if (isset($_GET['data'])){
		include "../class/functions.php";
		$dat=str_replace("'", "", $_GET['data']);
		$data=converteData($dat);
		$sql="select * from leituras where dia='".$data."' order by numero";
//		echo $sql;
		include_once("../class/class.php");
		$c=new ClassCon();
		
		$result=$c->seleciona($sql);
		if ($c->Ok($result)){
			$conf=true;
			while ($c->listar($result)){
				
				if ($conf){
					$lv1= $c->row["livro"];
					$l1=TiraBr($c->row["texto"]);
					$c2=new ClassCon();
					$sql="select * from salmos where dia='".$data."' order by numero";
					$r=$c2->seleciona($sql);
					if ($c2->Ok($r)){
						while ($c2->listar($r)){
							$lv3=$c2->row["livro"];
							$s=TiraBr($c2->row["texto"]);
						}
					}
				}else{
					$lv2= $c->row["livro"];
					$l2=TiraBr($c->row["texto"]);
				}
				$conf=false;
			}
			unset($c2);
		}

		$sql="select * from evangelios where dia='".$data."'";
		$result=$c->seleciona($sql);
		if ($c->Ok($result)){
			while ($c->listar($result)){
				$lv4= $c->row["livro"];
				$e=TiraBr($c->row["texto"]);
			}
		}
		$sql="select * from palavas where dia='".$data."'";
		$result=$c->seleciona($sql);
		if ($c->Ok($result)){
			while ($c->listar($result)){
				$p=TiraBr($c->row["texto"]);
			}
		}
		unset($c);	
			
	}
?>

<form action="leituras_insert.php" name="form1" method="post">
<center>
<table width="900">
<tr>
<td>data</td><td>
<input TYPE="button" NAME="dia" VALUE="<?php echo $dat;?>" Onclick="javascript:popdate('document.form1.dia','pop1','150','',false); ">
<input type="text" name="dia1" value='<?php echo $dat;?>'size="11" style="visibility: hidden"> 
<span id="pop1" style="position:absolute"></span>
</tr>

<tr>
<td>Primeira Leitura: <br /> 
livro: <input type="text" value="<?php echo $lv1; ?>" name="livro1" size="11"></td>
<td> <textarea WRAP="phisical" cols="70" rows="8" name="leitura1">
<?php echo $l1; ?>
</textarea></td>
</tr>
<tr>
<td>Salmo:<br /> livro: <input type="text" name="livros" "<?php echo $lv3; ?>"size="11"></td>
<td> <textarea WRAP="phisical" cols="70" rows="8" name="salmo">
<?php echo $s; ?></textarea></td>
</tr>
<tr>
<td>Segunda Leitura:<br /> 
livro: <input type="text" name="livro2" "<?php echo $lv2; ?>"size="11"></td>
<td> <textarea WRAP="phisical" cols="70" rows="8" name="leitura2">
<?php echo $l2; ?></textarea></td>
</tr>
<tr>
<td>Evangélio:<br /> 
livro: <input type="text" "<?php echo $lv4; ?>"name="livroe" size="11"></td>
<td> <textarea WRAP="phisical" cols="70" rows="8" name="evangelio">
<?php echo $e; ?></textarea></td>
</tr>
<tr>
<td>Palavra do Padre:</td>
<td> <textarea WRAP="phisical" cols="70" rows="8" name="palavra">
<?php echo $p; ?></textarea></td>
</tr>
<tr>
<td colspan=2 align="center"> 
<input type="button" value="Salvar" onClick="javascript:ValForm()"></td>
</tr>
</table>
</center>
</form> 
</body>
</html>